package com.tssf.car_manage.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tssf.car_manage.entity.RepairRecord;
import com.tssf.car_manage.mapper.RepairRecordMapper;
import com.tssf.car_manage.service.RepairRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service    //标记服务层（业务逻辑）
public class RepairRecordServiceImpl implements RepairRecordService {

    @Autowired //依赖注入
    RepairRecordMapper repairRecordMapper;

    @Override   //重写（Override）父类或接口中的方法
    public List<RepairRecord> listWithLicensePlate() {
        return repairRecordMapper.listWithLicensePlate(); // 使用带车牌号的查询
    }

    @Override
    public PageInfo<RepairRecord> listWithLicensePlate(int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        List<RepairRecord> list = repairRecordMapper.listWithLicensePlate();
        return new PageInfo<>(list);
    }

    @Override
    public List<RepairRecord> search(String key) {
        return repairRecordMapper.search(key);
    }

    @Override
    public PageInfo<RepairRecord> search(String key, int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        List<RepairRecord> list = repairRecordMapper.search(key);
        return new PageInfo<>(list);
    }

    @Override
    public int deleteById(int repair_id) {
        return repairRecordMapper.deleteById(repair_id);
    }

    @Override
    public int insert(RepairRecord repairRecord) {
        return repairRecordMapper.insert(repairRecord);
    }

    @Override
    public int update(RepairRecord repairRecord) {
        return repairRecordMapper.update(repairRecord);
    }

    @Override
    public RepairRecord getById(int repair_id) {
        return repairRecordMapper.getById(repair_id);
    }

}
